Skip to content

feat: add option to report ignores without comments#3976

Open
calebdw wants to merge 1 commit intophpstan:2.1.xfrom
calebdw:calebdw/push-qtlvsunynsrq
Open

feat: add option to report ignores without comments#3976
calebdw wants to merge 1 commit intophpstan:2.1.xfrom
calebdw:calebdw/push-qtlvsunynsrq

Conversation

@calebdw
Copy link
Contributor

@calebdw calebdw commented Apr 30, 2025

Hello!

Closes phpstan/phpstan#11340

This PR adds the following two option (false by default):

  • reportIgnoresWithoutIdentifiers: reports @phpstan-ignore-line and @phpstan-ignore-next-line usages
  • reportIgnoresWithoutComments: reports @phpstan-ignore usages without comments

Thanks!

@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from 94bcb68 to 47d8329 Compare April 30, 2025 18:29
@calebdw
Copy link
Contributor Author

calebdw commented Apr 30, 2025

CI failures look to be unrelated

@calebdw calebdw changed the title feat: add option to report ignores without identifiers feat: add options to report ignores without identifiers or comments Apr 30, 2025
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 2 times, most recently from 384c8af to 0475ff1 Compare April 30, 2025 21:05
@NanoSector
Copy link

Thanks for providing this & also picking up the case for no comments 🙌

@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from 0475ff1 to a63175b Compare May 10, 2025 21:44
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 2 times, most recently from e976b0d to 8e4e5f8 Compare May 22, 2025 12:25
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from 8e4e5f8 to 2a4b464 Compare May 29, 2025 13:04
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 3 times, most recently from ae45feb to 3b7dc03 Compare June 21, 2025 04:43
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from 3b7dc03 to 3154768 Compare July 14, 2025 18:54
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from 3154768 to e36cd48 Compare September 13, 2025 12:35
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from e36cd48 to eb04e1d Compare November 26, 2025 14:33
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 2 times, most recently from f6aba44 to db2e46f Compare January 23, 2026 22:17
@ondrejmirtes
Copy link
Member

I'm thinking about deprecating @phpstan-ignore-line and @phpstan-ignore-next-line completely now and removing them in 3.0. Because people often use them with identifiers by mistake, but these comments ignore all errors anyway. So I don't want to add reportIgnoresWithoutIdentifiers now.

We'd have to add a support for new comment @phpstan-ignore-all-errors to have a replacement for these though.

As for reportIgnoresWithoutComments, yeah, that one makes sense to me and I'd accept it.

@calebdw
Copy link
Contributor Author

calebdw commented Feb 11, 2026

Sounds good---I'll update

We'd have to add a support for new comment @phpstan-ignore-all-errors to have a replacement for these though.

That's good---however, consider adding an option to enable/disable this when the new comment is added. Some projects may want to complete disable this and not allow such a global ignore

@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from db2e46f to b1cedbf Compare February 11, 2026 16:38
@calebdw calebdw changed the title feat: add options to report ignores without identifiers or comments feat: add option to report ignores without comments Feb 11, 2026
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 4 times, most recently from 1d62fec to 5dd8312 Compare February 11, 2026 17:17
@derrabus
Copy link

I'm thinking about deprecating @phpstan-ignore-line and @phpstan-ignore-next-line completely now and removing them in 3.0. Because people often use them with identifiers by mistake, but these comments ignore all errors anyway. So I don't want to add reportIgnoresWithoutIdentifiers now.

A deprecation would also work for me. I want to rid my codebases of those annotations, so as long as an error pops up if one of the old annotations is used, I'm happy. ✌🏻

@calebdw
Copy link
Contributor Author

calebdw commented Feb 11, 2026

@ondrejmirtes, this is ready for review 👍

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Feb 15, 2026

That's good---however, consider adding an option to enable/disable this when the new comment is added. Some projects may want to complete disable this and not allow such a global ignore

This feel like a very special/opinionated rules which might make more sens in a dedicated repository or just in your personal project IMHO.

And there is already some way to achieve this like using PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/rules/phpdoc/general_phpdoc_annotation_remove.rst
and configuring those tag as "to remove".

Certainly the same could exist with PHP CodeSniffer or Rector or any linter.

I personally think the same about reportIgnoresWithoutComments but I let ondrej decide

@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 2 times, most recently from 124320a to ec940ab Compare February 18, 2026 09:20
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch from ec940ab to 3195405 Compare February 18, 2026 10:39
@calebdw calebdw force-pushed the calebdw/push-qtlvsunynsrq branch 2 times, most recently from d297b1b to ed3c1c9 Compare February 18, 2026 14:14
@staabm staabm force-pushed the calebdw/push-qtlvsunynsrq branch from ed3c1c9 to 514ee6a Compare February 19, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to disable phpstan-ignore-line and phpstan-ignore-next-line

6 participants

Comments